package com.platform.comm.validation.constraints;

import com.platform.comm.validation.CandidatesValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 自定义Bean Validation Annotation<br>
 * 校验字符串候选值
 * @author libin
 */
@Target({METHOD, FIELD, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = CandidatesValidator.class)
public @interface Candidates {

    /**
     * 候选值集合
     */
    String[] value() default {};

    /**
     * 是否可空
     */
    boolean nullable() default true;

    String message() default "{com.platform.core.comm.validation.constraints.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
